/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 前台小姐姐具体通知者
 * @Description *
 * @Package designmodel.observe2.notify
 * @date 2021/3/4 11:36 上午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.observe2.notify;

import designmodel.observe2.observer.Observer;

import java.util.ArrayList;
import java.util.List;

public class FrontDeskLittleSister implements Notifier {

    List<Observer> observers = new ArrayList<>();

    private String action;

    @Override
    public FrontDeskLittleSister add(Observer observer) {
        if (!observers.contains(observer)) observers.add(observer);
        return this;
    }

    @Override
    public FrontDeskLittleSister del(Observer observer) {
        observers.remove(observer);
        return this;
    }

    @Override
    public void notifyObservers(String action) {
        for (Observer observer : observers) {
            observer.update(action);
        }
    }

    public void teacherIsComing(String action) {
        this.action = action;
    }
}
